﻿namespace KinonekoSoftware.CodariaDB.Documents.Theories
{
    public abstract class Theory : EmbeddedObject
    {
        /// <summary>
        /// 版本
        /// </summary>
        public int Version { get; set; }

        /// <summary>
        /// 允许覆盖当前的元素设定名称，你可以改为 属性设定等。
        /// </summary>
        public string TheoryName { get; set; }
    }

    public abstract class TheoryObject : FullObject, IGlossary, INotion, IStory, IGlossaryOperation
    {
        void IGlossaryOperation.Add(Engine engine)
        {
            engine.Queue
                  .OnNext(new ConceptOP_MSG
                   {
                       ConceptID       = Id,
                       ConceptIntro    = Intro,
                       ConceptName     = Name,
                       ConceptEngineID = engine.EngineID,
                       Action          = Database_Action.Added,
                   });
        }

        void IGlossaryOperation.Update(Engine engine)
        {
            engine.Queue
                  .OnNext(new ConceptOP_MSG
                   {
                       ConceptID    = Id,
                       ConceptIntro = Intro,
                       ConceptName  = Name,
                       Action       = Database_Action.Modified,
                   });
        }

        void IGlossaryOperation.Remove(Engine engine)
        {
            engine.Queue.OnNext(new ConceptOP_MSG
            {
                ConceptID   = Id,
                ConceptName = Name,
                Action      = Database_Action.Removed,
            });
        }

        string IGlossary.Id => Id;

        string INotion.Id   => Id;
        string INotion.Name => Name;
        

        string IStory.Id   => Id;
        string IStory.Name => Name;

        private string _name;
        private string _intro;
        
        public string Intro
        {
            get => _intro;
            set => SetValue(ref _intro, value);
        }
        
        public string Name
        {
            get => _name;
            set => SetValue(ref _name, value);
        }
    }
}